package com.zhou.common.mybatis.template.shiro.config;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;

//@EnableWebSecurity
/*@EnableGlobalMethodSecurity(
        securedEnabled = true,
        jsr250Enabled = true,
        prePostEnabled = true
)*/
public class MultiHttpSecurityConfig {


    //@Order(-1)
    //@Import(AuthorizationServerEndpointsConfiguration.class)
    //@Configuration
    public class JwkSetEndpointConfiguration extends AuthorizationServerSecurityConfiguration {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            super.configure(http);
            http
                    .requestMatchers()
                    .mvcMatchers("/.well-known/jwks.json")
                    .and()
//                    .exceptionHandling().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login")).and()

                    .authorizeRequests()
                    .mvcMatchers("/.well-known/jwks.json").permitAll()
                    .anyRequest().authenticated()
                .and()
                .formLogin()
                .and()
//                    .apply(new DefaultLoginPageConfigurer<HttpSecurity>()).and()
                .csrf().disable()
                ;
        }

        /*@Bean
        @Override
        public UserDetailsService userDetailsService() {
            return new InMemoryUserDetailsManager(
                    User.withDefaultPasswordEncoder()
                            .username("enduser")
                            .password("password")
                            .roles("USER")
                            .build());
        }

        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
            auth
                   .userDetailsService(userDetailsService());
        }


        @Override
        @Bean
        public AuthenticationManager authenticationManagerBean() throws Exception {
            return super.authenticationManagerBean();
        }*/

    }

}